# # -*- coding: utf-8 -*-
# # @Time    : 2021/4/24 11:28
# # @Author  : xxue
# # @Email   : x_xue1212@163.com
# # @File    : 作业.py
# # @Software: PyCharm
#
# ###############1
# # 利用map批量检测用户名是否符合规范=> username符合规范, username不符合规范
# # 只能包含数据、字母、下划线，不以数字开头，长度在6-18之间
# # filter把合法的用户名显示出来
#
# import re
# username=[]
# while 1:
#     username.append(input("请输入用户名："))
#     if username=='q':
#         break
#     print(f"username={username}")
#     def username_check(username):
#         ret = re.findall(r"^[a-zA-z_][\w]{5,17}", username)
#         # 判断是否符合规范
#         if ret==[]:
#             return username+"不符合规范"
#         else:
#             return username+"符合规范"
#     result=map(username_check,username)
#     print(list(result))

# filter把合法的用户名显示出来
# def filter_legal():
#     for i in list(result):
#         if "符合规范" in i:
#             return i
# print(list(filter(filter_legal,username)))
#
# ############################3
# # 匿名函数  reduce 实现1*2*3*..*n
# from functools import reduce
# n = int(input("请任意输入一个数字："))
# print(reduce(lambda x,y:x*y,range(1,n+1)))
#
# ##########################4
# # filter函数 找出[1-100] 能被3整数的数
# print(list(filter(lambda x: x % 3 == 0, range(1, 101))))
#
#
# # ####################5
# # map函数：求list[1-10]各项的平方
# print(list(map(lambda x: x ** 2, range(1, 11))))
#
#
# # #####################6
# # 将列表[1,4,5,9]转换成'1459'的字符串
# from functools import reduce
# lst2 = [1,4,5,9]
# print(reduce(lambda x,y:str(x)+str(y),lst2))
# print(type(reduce(lambda x,y:str(x)+str(y),lst2)))
# #查看类型
#


# 有以下列表： lst1=[7,-8,5,4,0,-2,-5]
# 正数在前负数在后
# 正数从小到大
# 负数从大到小
# 预想结果：lst1 = [4,5,7 ,0, -2, -5,-8]


# lst1 = [7, -8, 5, 4, 0, -2, -5]
# lst_low = []
# lst_up = []
# for i in lst1:
#     if i < 0:
#         lst_low.append(i)
#     elif i > 0:
#         lst_up.append(i)
# lst = sorted(lst_up) + [0] + sorted(lst_low, reverse=True)
# print(lst)


lst1=[7,-8,5,4,0,-2,-5]
print(sorted(lst1,key=lambda x: (x<=0,abs(x))))


# 这是一个字符串排序，排序规则:小写<大写<奇数<偶数
# s='asdf1234GDSdsf23' 排序：小写-大写-奇数-偶数
# 原理：先比较元组的第一个值,FALSE
# 预想结果 ：addffssDGS133224

from functools import reduce
s='asdf1234GDSdsf23'
# lst_lower=[]
# lst_upper=[]
# lst_odd=[]
# lst_even=[]
# for i in s:
#     if i.islower():
#         lst_lower.append(i)
#     elif i.isupper():
#         lst_upper.append(i)
#     elif i.isdigit():
#         lst_even.append(i) if int(i)%2==0 else lst_odd.append(i)
# lst=sorted(lst_lower)+sorted(lst_upper)+sorted(lst_odd)+sorted(lst_even)
# print(reduce(lambda x,y:str(x)+str(y),lst))


lst2=sorted(s,key=lambda x:(x.isdigit(),x.isdigit() and int(x)%2==0,x.isupper(),x))
print(reduce(lambda x,y:str(x)+str(y),lst2))
